import { Skeleton } from 'antd-mobile'
import type { SkeletonTitleProps } from 'antd-mobile/es/components/skeleton'

type Props = SkeletonTitleProps & {
    loading: boolean
    children: React.ReactNode
}

export const SkeletonTitleWrap = (props: Props) => {
    const { loading = false, children } = props

    const getComponentOriginProps = () => {
        const originProps = props
        Reflect.deleteProperty(originProps, 'loading')
        Reflect.deleteProperty(originProps, 'children')
        return originProps
    }

    return loading ? <Skeleton.Title {...getComponentOriginProps()} /> : <>{children}</>
}
